﻿from qiniu import Auth, put_file, etag
import uuid




def upload_img(file_path):


    # 获取Access Key 和 Secret Key 后，进行初始化对接：
    q = Auth(access_key='XHQUJJIDT4eRgM7u0Ns9j9nnKw6ZS4a3F32-bnC7',
             secret_key='Mo_kgVdC0a5yMzMXveYosKcPyPJwigp3u_5DSa0s')

    # 上传的七牛云空间
    bucket_name = 'ourgamemap'

    # 生成上传token
    token = q.upload_token(bucket_name)

    # 指定图片名称  随机
    #file_name = '{}.png'.format(uuid.uuid4())
    file_name =uuid.uuid4()

    #域名
    domain_name = 'https://kb.violet-umberto.com/'


    ret, info = put_file(token,  file_name, file_path)
    img_url = domain_name + ret.get('key')


    return img_url




